<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script type="text/javascript" src="../../../src/base/_core.js"></script>
    <script type="text/javascript" src="../../../src/core/env.js"></script>
</head>
<body>
<div id="div1" style="width:200px; height:200px; border: 1px solid #f00; background: #eee;"></div>
<div id="div2" style="width:300px; height:200px; border: 1px solid #0f0; background: #ccc;"></div>

<table id="tb1">
    <tr>
        <td><a href="#">baidu</a></td>
        <td><a href="#">sina</a></td>
        <td><a href="#">网易</a></td>
    </tr>
    <tr>
        <td><a href="#">baidu</a></td>
        <td><a href="#">sina</a></td>
        <td><a href="#">网易</a></td>
    </tr>
</table>

<textarea name="" id="tx1" cols="30" rows="10"></textarea>

<script type="text/javascript">
    /**
     * Jquery事件对象作了cache:

     if (event[ jQuery.expando ]) {
     return event;
     }

     */
    (function (line, browser, document, window) {
        var ln = {
            getDoc:function (element) {
                var doc = document;
                if (element) {
                    doc = (element.nodeType === 9) ? element : // element === document
                            element.ownerDocument || // element === DOM node
                                    element.document// element === window
                }
                return doc;
            },
            getWin:function (element) {
                var doc = ln.getDoc(element);
                return doc.defaultView || doc.parentWindow || window;
            },
            getEvent:function (event) {
                return event || ln.getWin().event;
            },
            getEventDoc:function (event) {
                var target = ln.getTarget(event);
                return event.target.ownerDocument || document;
            },
            getEventRoot:function (event) {
                var eventDoc = ln.getEventDoc(event);
                return  (browser.isStrict) ? eventDoc.documentElement : eventDoc.body;
            },
            getTarget:function (event) {
                return event.srcElement || document;
            },
            getRelatedTarget:function (event) {
                var fromElement = event.fromElement,
                        target = ln.getTarget(event);
                return (fromElement === target) ? event.toElement : fromElement
            },
            getWhich:function (event) {
                var button = event.button;
                return ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
            },
            getMetaKey:function (event) {
                return !!event.metaKey;
            },
            getPageX:function (event) {
                var root = ln.getEventRoot(event);
                return event.clientX + ( root.scrollLeft || 0 ) - ( root.clientLeft || 0 );
            },
            getPageY:function (event) {
                var root = ln.getEventRoot(event);
                return event.clientY + ( root.scrollTop || 0 ) - ( root.clientTop || 0 );
            },
            getOffsetX:function(event){
                var target=ln.getTarget(event);
                var offsetLeft=line.dom.offset(target).left;
                return ln.getPageX(event)-offsetLeft;
            },
            getOffsetY:function(event){
                var target=ln.getTarget(event);
                var offsetTop=line.dom.offset(target).top;
                return ln.getPageY(event)-offsetTop;
            },
            normalize:function (event, original) {
                var eventDoc, root,
                        button = original.button,
                        fromElement = original.fromElement;
                if (!event.target) {
                    event.target = original.srcElement || document;
                }
                if (event.pageX == null && original.clientX != null) {
                    eventDoc = event.target.ownerDocument || document;
                    root = (browser.isStrict) ? eventDoc.documentElement : eventDoc.body;
                    event.pageX = original.clientX + ( root.scrollLeft || 0 ) - ( root.clientLeft || 0 );
                    event.pageY = original.clientY + ( root.scrollTop || 0 ) - ( root.clientTop || 0 );
                }
                if (!event.relatedTarget && fromElement) {
                    event.relatedTarget = (fromElement === event.target) ? original.toElement : fromElement;
                }
                if (!event.which && button !== undefined) {
                    event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
                }

                //offsetX,offsetY

                event.metaKey = !!event.metaKey;
                return event;
            }

        };
        window.ln = ln;
    }(line, line.browser, document, window));
    var div1 = document.getElementById('div1');
    var div2 = document.getElementById('div2');
    var tb1 = document.getElementById('tb1');
    var tx1 = document.getElementById('tx1');

    //MouseEvent
    div1.onclick = function (ev) {
        console.log('mouse click :',ev);
    };
    //MouseEvent
    div2.onmouseover = function (ev) {
        console.log('mouse over :',ev);
    };
    //MouseEvent
    tb1.onmouseover = function (ev) {
        console.log('tb1 mouse over :',ev);
    };

    //instance of :Event
    tx1.oninput=function(ev){
        console.log('tx1 input ..',ev);
    };

    //instanceof :KeyboardEvent
    tx1.onkeydown=function(ev){
        console.log('tx1 keydonw',ev);
    };
</script>
</body>
</html>